<?php
namespace app\common\validate\jy;

class Pay extends Base {
	/**
     * 验证规则
     */
    protected $rule = [
    	'lock'         => 'require',
        'id'           => 'require|isUser:jy\\Order|pay',
        'uid'          => 'require'
    ];
    /**
     * 提示消息
     */
    protected $message = [
    	'lock.require'             => '验证规则场景不存在',
        'id.require'               => '订单ID不能为空',
        'id.isUser'                => '订单不属于您',
        'id.pay'                   => '订单不是待支付状态',
        'uid.require'              => 'uid不能为空'
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'order'   => ['id', 'uid']
    ];

    //店铺ID
    protected function pay($value, $rule, $data = []) {
        $statusEnum = loadEnum('OrderStatus');
        $row = loadOnly('Model')->find('jy\\Order', $value);
        return $row['status'] == $statusEnum->code2key('daizhifu');
    }
}
